package com.microservice.api.consumer;

import com.microservice.api.consumer.fallbackFactory.RemoteConsumeFallbackFactory;
import com.microservice.core.domain.AjaxResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

/**
 * 下面的方式二选一,第一种请求从网关走(url配置在nacos上)，第二种请求直接请求服务提供方
 * openfeign请求其他服务接口时，默认是不走gateway网关的,这里配置了url,使其走gateway网关路由,再通过路由转发到对应请求所在的模块服务
 * 比如这里的请求是producer-module->openfeign->consumer-module,配置了url后,请求路线变为如下
 * consumer-module->openfeign->gateway-module->consumer-module
 * 注意需要加上path调用远程模块的请求前缀，方便gateway根据前缀进行路由转发
 */

//@FeignClient(contextId = "remoteConsumerService",
//        value = FeignConstants.CONSUMER_SERVICE_NAME,
//        url = "${service.gateway-base-url}",
//        path = FeignConstants.PREFIX_CONSUMER_PATH,
//        fallback = RemoteConsumeFallback.class)

@FeignClient(contextId = "remoteConsumerService",
        value = "consumer-module",
        fallbackFactory = RemoteConsumeFallbackFactory.class)

public interface RemoteConsumerService {

    @GetMapping(value = "/message/handle")
    AjaxResult getConsumeMessage();

    @PostMapping(value = "/message/commit")
    AjaxResult consumeMessagePost();

}
